{extend name="common/application" /}
{block name="title"}<title id="title">店铺中心-交易申诉</title>{/block}
{block name="css"}
<link rel="stylesheet" type="text/css" href="_CSS_/reset.css">
<link rel="stylesheet" type="text/css" href="_CSS_/common.css">
<link rel="stylesheet" type="text/css" href="_CSS_/help.css"/>
<link rel="stylesheet" type="text/css" href="_CSS_/store_center.css"/>
<!--[if lt IE 9]>
<script src="http://www.ijquery.cn/js/html5shiv.js"></script>
<![endif]-->
<style type="text/css">
	.nodatas{text-align:center;padding:100px 0;width:850px;}
	.nodatas img{margin:100px 0 50px 0;}
</style>
{/block}

{block name="content"}
<!-- 主体内容 -->
<div class="main">
    <div class="mainBody normalBox clearfix">
        <!--左菜单-->
        {include file="/common/left" /}
        <!--右内容-->
        <div class="menuContent fr">
            <div class="menuConHeader">
                <!--面包屑导航-->
                <div class="breadcrumb">
                    <p>
                        <a href="javascript:;">消息中心</a> &gt;
                        <a class="curPage" href="{:url('index/store/complain')}">交易申诉</a>
                    </p>
                </div>
            </div>
            <input type="hidden" id="value">
            <div class="menuConBody">
                <div class="courseMenu">
                    <div class="courseSelect bor-btno">
                        <ul>
                            <li class="selected">
                                <a class="selectType" href="javascript:;">全部</a>
                            </li>
                            <li>
                                <a class="selectType" href="javascript:;">未处理</a>
                            </li>
                            <li>
                                <a class="selectType" href="javascript:;">处理中</a>
                            </li>
                            <li>
                                <a class="selectType" href="javascript:;">已完成</a>
                            </li>
                        </ul>
                    </div>
                    <div class="conBody">
                        <div class="complain-box">
                            <table>
                                <thead>
                                <tr class="thead hide">
                                    <th width="170">订单编号</th>
                                    <th width="300">问题描述</th>
                                    <th width="170">申诉时间</th>
                                    <th width="155">申诉状态</th>
                                    <th width="138">操作</th>
                                </tr>
                                </thead>
                                <tbody>


                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div id="page"></div>
                </div>
            </div>

        </div>
    </div>
</div>
{/block}
{block name="js"}
<!-- 脚本引入 -->
<script src="_P_/layer/layer.js"></script>
<script>
    $(document).ready(function () {
        /*处理状态切换*/
        $(".courseSelect li").on("click", function () {
            var num = $(".courseSelect li").index(this);
            $(".courseSelect li").removeClass("selected");
            $(this).addClass("selected");
            $("#value").val(num);
            postfile(1, num)
        });
        $('.li4').addClass('showChild');
        $('.li40').addClass('activeMenu');
    });

    $(function () {
        postfile(1, 0);
    });

    /*查看详情*/
    function view_details(id) {
        layer.open({
            type: 2,
            title: '查看详情',
            skin: 'layui-layer-lan',
            area: ['670px', '500px'], //宽高
            content: 'details.html#' + id
        });
    }


    function postfile(page, value) {
        var userinfo = $.cookie('userinfo');
        if (userinfo != null) {
            var user_login = $.base64.decode(userinfo).split(",");
            $.ajax({
                type: "get",
                url: "{:url('api/shop/complain')}",
                data: {'uid': user_login[0], 'page': page, 'static': value},
                dataType: 'jsonp',
                success: function (msg) {
                    if (msg.code == 200) {
                        $(".complain-box tbody").html("");
                        if (msg.data.data.length != 0) {
						$('tr.thead').removeClass("hide");
                            for (var i = 0; i < msg.data.data.length; i++) {
                                var html = ' <tr><td>' + msg.data.data[i].order + '</td><td>' + msg.data.data[i].problem + '</td>';
                                if (msg.data.data[i].static == 1) {
                                    html += '<td>' + getMyDate(msg.data.data[i].time * 1000) + '</td><td>未处理</td>';
                                } else if (msg.data.data[i].static == 2) {
                                    html += '<td>' + getMyDate(msg.data.data[i].time * 1000) + '</td><td>待处理</td>';
                                } else if (msg.data.data[i].static == 3 || msg.data.data[i].static == 4) {
                                    html += '<td>' + getMyDate(msg.data.data[i].time * 1000) + '</td><td>已处理</td>';
                                }
                                html += '<td><a class="cl-b" href="javascript:;" onclick="view_details(' + msg.data.data[i].id + ')">查看详情</a></td></tr>';
                                $(".complain-box tbody").append(html);
                            }
                            if (msg.data.count == 0) {
                                $('#page').html('');
                            } else {
                                $('#page').html(msg.data.render);
                                $("#pagination").delegate("a", "click", function () {
                                    var num = $(this).attr("num");
									var value = $("#value").val();
                                    if (num) {
                                        postfile(num, value);
                                    }
                                });
								var pages = Math.ceil(msg.data.count / 10);
								$("#GO").on('click',function(){
									var king = $("#go").val();
									if(king > pages){
										layer.alert("最多输入"+pages+"页");
										return;
									}
									postfile(king, value);
								});
                            }
                        } else {
                            $("#page").html("");
							$(".complain-box tbody").html("<div class='nodatas normalBox'><img src='/static/web/images/nodata.png'/><p>抱歉，找不到相关数据</p></div>");
							$('tr.thead').addClass("hide");
                        }
                    }
                }
            })
        } else {
            window.location.href = "{:url('index/login/index')}";
        }
    }

</script>
{/block}